import { tooltip, seriesConfig, legendConfig } from './pieParams'

// 告警设备饼图
export const alarmDevicePie = (seriesData) => {

  let color = '#2f4159'
  if (seriesData.length < 1) {
    seriesData.push({
      name: '',
      value: 0
    })
  } else {
    color = ['#18b6db', '#5fd181', '#ffb400', '#9bb1bf','#947EB5']
  }

  const { clientWidth:w } = document.body

  return {
    title: { 
      text: '告警设备',
      subtext: '类型',
      textAlign: 'center',
      textStyle: {
        color: '#fff',
        fontSize: w/1920 * 20,
        align: 'center',
        rich: {
          align: 'center'
        }
      },
      subtextStyle: {
        color: '#fff',
        fontSize: w/1920 * 20,
        align: 'center',
        rich: {
          align: 'center'
        }
      },
      top: '40%',
      left: '39%'
    },
    tooltip,
    color,
    legend: {
      ...legendConfig,
      right:'0%',
      top:'30%',
      lineHeight:'center',
      data: ['咖啡机', '冷藏冰箱', '空调', '冷冻冰箱','温湿度传感器']
    },
    series: [
      {
        ...seriesConfig,
        data: seriesData
      }
    ]
  }
  
}